﻿using AutoMapper;

namespace HobSoft.SoccerBet2014.Client.ModelsMapper
{
    using dm = Domain.Models;
    using vm = ViewModels;
    public class BetToConverter : ITypeConverter<dm.OddsPrice.OddsPriceType, vm.BetItem>
    {
        public vm.BetItem Convert(ResolutionContext context)
        {
            vm.BetItem result = vm.BetItem.Tie;
            var priceType = (dm.OddsPrice.OddsPriceType)context.SourceValue;
            switch (priceType)
            {
                case dm.OddsPrice.OddsPriceType.Home:
                case dm.OddsPrice.OddsPriceType.Over:
                    result = vm.BetItem.HomeOrOver;
                    break;
                case dm.OddsPrice.OddsPriceType.Away:
                case dm.OddsPrice.OddsPriceType.Under:
                    result = vm.BetItem.AwayOrUnder;
                    break;
                case dm.OddsPrice.OddsPriceType.Tie:
                    result = vm.BetItem.Tie;
                    break;
                default:
                    break;
            }
            return result;
        }
    }
}
